package cn.media

import org.apache.spark.{SparkConf, SparkContext}
import org.apache.spark.rdd.RDD

object madiaV2 {

  def main(args: Array[String]): Unit = {

    if(args.length!=1){
      println(
        """
          |参数：
          |inputpath
          |""".stripMargin)
      sys.exit()
    }
    val Array(inputpath) = args

    val conf: SparkConf = new SparkConf().setAppName("madiaV2").setMaster("local[*]")
    val sc: SparkContext = new SparkContext(conf)

    sc.textFile(inputpath)
      .map(line => line.split("\t", -1))
      .map(arr => (arr(4), arr(1)))
      .reduceByKey(_ + _)
      .map(t => t._1+","+t._2)
      .saveAsTextFile("D:\\logs\\cs")

    sc.stop()

  }

}
